//
//  JYPicPickerViewCell.swift
//  WeiBoDemo
//
//  Created by 万佳阳 on 16/8/5.
//  Copyright © 2016年 JYWan. All rights reserved.
//

import UIKit

class JYPicPickerViewCell: UICollectionViewCell {
    // MARK:- 自定义属性
    var image : UIImage? {
        didSet {
            if let image = image {
                imageView.image = image
                addPhotoBtn.userInteractionEnabled = false
                closePhotoBtn.hidden = false
            } else {
                imageView.image = nil
                addPhotoBtn.userInteractionEnabled = true
                closePhotoBtn.hidden = true
            }
        }
    }
    
    // MARK:- 控件属性
    @IBOutlet weak var addPhotoBtn: UIButton!
    @IBOutlet weak var closePhotoBtn: UIButton!
    @IBOutlet weak var imageView: UIImageView!
    

    // MARK:- 事件监听
    @IBAction func addPhotoBtnClick() {
        //创建通知
        NSNotificationCenter.defaultCenter().postNotificationName(picPickerAddPhotoNote, object: nil)
        
    }

    @IBAction func closePhotoBtnClick() {
        NSNotificationCenter.defaultCenter().postNotificationName(picPickerClosePhotoNote, object: imageView.image)
    }
}
